<template>
  <div class="qq-register-container">
    <h1>欢迎注册QQ</h1>
    <p>每一天，乐在沟通。</p>

    <div class="form-group">
      <input type="text" v-model="nickname" placeholder="昵称" />
      <div v-if="!nickname" class="error-tip">① 昵称不可为空</div>
    </div>

    <div class="form-group">
      <input type="password" v-model="password" placeholder="密码" />
      <div v-if="!password" class="error-tip">① 密码不能为空</div>
    </div>

    <div class="form-group phone-group">
      <select v-model="countryCode">
        <option value="+86">+86</option>
      </select>
      <input type="text" v-model="phone" placeholder="手机号码" />
      <div v-if="!phone" class="error-tip">① 请填写手机号</div>
    </div>

    <div v-if="phone" class="form-group verify-code-group">
      <input type="text" v-model="verifyCode" placeholder="短信验证码" />
      <button @click="sendVerifyCode">发送验证码</button>
    </div>

    <div class="agreement-group">
      <input type="checkbox" v-model="agreeTerms" />
      <span>我已阅读并同意服务协议和QQ隐私保护指引</span>
    </div>

    <button class="register-btn" :disabled="!agreeTerms">立即注册</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      nickname: '',
      password: '',
      countryCode: '+86',
      phone: '',
      verifyCode: '',
      agreeTerms: false,
    }
  },
  methods: {
    sendVerifyCode() {
      console.log('发送验证码到', this.phone)
    },
  },
}
</script>

<style scoped>
.qq-register-container {
  width: 340px;
  margin: 50px auto;
  padding: 20px;
  background: linear-gradient(180deg, #f0f8ff 0%, #e6f7ff 100%);
  border-radius: 8px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 15px;
}

p {
  color: #333;
  font-size: 16px;
  margin-bottom: 25px;
}

.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
}

.phone-group {
  flex-direction: row;
  align-items: center;
}

.phone-group input {
  flex: 1;
  margin-left: 8px;
}

.form-group input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

.form-group input.error-border {
  border-color: #ff4d4f;
}

.error-tip {
  color: #ff4d4f;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 4px;
}

select {
  width: 60px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.verify-code-group {
  display: flex;
  align-items: center;
}

.verify-code-group input {
  flex: 1;
  margin-right: 8px;
}

.verify-code-group button {
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.agreement-group {
  display: flex;
  align-items: center;
  margin: 15px 0;
}

.agreement-group input {
  width: 16px;
  height: 16px;
  margin-right: 8px;
}

.agreement-group span {
  font-size: 14px;
  color: #666;
}

.register-btn {
  width: 100%;
  padding: 12px;
  background-color: #007aff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}
</style>
